package dreic;

import scala.collection.immutable.ListMap;

class Scope {
    var scope: ListMap[Name, Symbol] = new ListMap
    def enter(sym: Symbol): Unit = {
        scope = scope.update(sym.name, sym);
    }
    def lookup(name: Name): Option[Symbol] = scope.get(name);
    def remove(sym: Name): Unit = {
      scope = scope.-(sym);
    }
}

class ClassScope {
    var classScope: ListMap[Name, ClassSymbol] = new ListMap
    def enter(sym: ClassSymbol): Unit = {
        classScope = classScope.update(sym.name, sym);
    }
    def lookup(name: Name): Option[ClassSymbol] = classScope.get(name);
    def remove(sym: Name): Unit = {
      classScope = classScope.-(sym);
    }
}

class FieldScope {
    var fieldScope: ListMap[Name, FieldSymbol] = new ListMap
    def enter(sym: FieldSymbol): Unit = {
        fieldScope = fieldScope.update(sym.name, sym);
    }
    def lookup(name: Name): Option[FieldSymbol] = fieldScope.get(name);
    def remove(sym: Name): Unit = {
      fieldScope = fieldScope.-(sym);
    }
}

class MethodScope {
    var methodScope: ListMap[Name, MethodSymbol] = new ListMap
    def enter(sym: MethodSymbol): Unit = {
        methodScope = methodScope.update(sym.name, sym);
    }
    def lookup(name: Name): Option[MethodSymbol] = methodScope.get(name);
    def remove(sym: Name): Unit = {
      methodScope = methodScope.-(sym);
    }
}

class VarScope {
    var varScope: ListMap[Name, VarSymbol] = new ListMap
    def enter(sym: VarSymbol): Unit = {
        varScope = varScope.update(sym.name, sym);
    }
    def lookup(name: Name): Option[VarSymbol] = varScope.get(name);
    def remove(sym: Name): Unit = {
        varScope = varScope.-(sym);
    }
}